<?php

/*
 * This file is part of PHP CS Fixer.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *     Dariusz Rumiński <dariusz.ruminski@gmail.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace app\common\lib;

class Aes
{
    private $key = 'abcdefgabcdefg12';

    public function __construct($key = '')
    {
        $key && $this->key = $key;
    }

    public function encrypt($input)
    {
        $data = openssl_encrypt($input, 'AES-128-ECB', $this->key, OPENSSL_RAW_DATA);

        return base64_encode($data);
    }

    public function decrypt($input)
    {
        return openssl_decrypt(base64_decode($input,true), 'AES-128-ECB', $this->key, OPENSSL_RAW_DATA);
    }
}
